class IntegralExchangeModel {
  String? id;
  String? name;
  int? duration;
  int? type;
  String? desc;
  String? img;
  int? price;
  int? prize;

  IntegralExchangeModel({this.id, this.name, this.duration, this.type, this.desc, this.img, this.price});

  IntegralExchangeModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    duration = json['duration'];
    type = json['type'];
    desc = json['desc'];
    img = json['img'];
    price = json['price'];
    prize = json['prize'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['duration'] = this.duration;
    data['type'] = this.type;
    data['desc'] = this.desc;
    data['bgImg'] = this.img;
    data['price'] = this.price;
    return data;
  }
}

class TaskCenterData {
  List<DailyTask>? dailyTask;
  List<DailyTask>? onceTask;
  List<DailyTask>? taskList;
  List<DailyTask>? growthTasks;
  List<DailyTask>? noviceTaskList;
  List<DailyTask>? growthTaskList;

  TaskCenterData({
    List<DailyTask>? dailyTaskList,
    List<DailyTask>? noviceTaskList,
    List<DailyTask>? taskList,
  });

  TaskCenterData.fromJson(dynamic json) {
    if (json['dailyTask'] != null) {
      dailyTask = [];
      json['dailyTask'].forEach((v) {
        dailyTask?.add(DailyTask.fromJson(v));
      });
    }
    if (json['onceTask'] != null) {
      onceTask = [];
      json['onceTask'].forEach((v) {
        onceTask?.add(DailyTask.fromJson(v));
      });
    }
    if (json['growthTasks'] != null) {
      growthTasks = [];
      json['growthTasks'].forEach((v) {
        growthTasks?.add(DailyTask.fromJson(v));
      });
    }
    if (json['taskList'] != null) {
      taskList = [];
      json['taskList'].forEach((v) {
        taskList?.add(DailyTask.fromJson(v));
      });
    }
    if (json['noviceTaskList'] != null) {
      noviceTaskList = [];
      json['noviceTaskList'].forEach((v) {
        noviceTaskList?.add(DailyTask.fromJson(v));
      });
    }
    if (json['growthTaskList'] != null) {
      growthTaskList = [];
      json['growthTaskList'].forEach((v) {
        growthTaskList?.add(DailyTask.fromJson(v));
      });
    }
  }
}

class Prizes {
  String? id;
  String? activityId;
  String? vipCardId;
  String? name;
  num? type;
  num? count;
  int? price;
  num? sort;
  String? desc;
  num? value;
  String? weights;
  num? level;
  bool? status;
  num? validityTime;
  String? image;
  String? updateTime;
  String? createTimt;

  Prizes({
    this.id,
    this.activityId,
    this.vipCardId,
    this.name,
    this.type,
    this.count,
    this.price,
    this.sort,
    this.desc,
    this.value,
    this.weights,
    this.level,
    this.status,
    this.validityTime,
    this.image,
    this.updateTime,
    this.createTimt,
  });

  Prizes.fromJson(dynamic json) {
    id = json['id'];
    activityId = json['activityId'];
    vipCardId = json['vipCardId'];
    name = json['name'];
    type = json['type'];
    count = json['count'];
    price = json['price'];
    sort = json['sort'];
    desc = json['desc'];
    value = json['value'];
    weights = json['weights'];
    level = json['level'];
    status = json['status'];
    validityTime = json['validityTime'];
    image = json['image'];
    updateTime = json['updateTime'];
    createTimt = json['createTimt'];
  }

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['activityId'] = activityId;
    map['vipCardId'] = vipCardId;
    map['name'] = name;
    map['type'] = type;
    map['count'] = count;
    map['price'] = price;
    map['sort'] = sort;
    map['desc'] = desc;
    map['value'] = value;
    map['weights'] = weights;
    map['level'] = level;
    map['status'] = status;
    map['validityTime'] = validityTime;
    map['image'] = image;
    map['updateTime'] = updateTime;
    map['createTimt'] = createTimt;
    return map;
  }
}

class DailyTask {
  String? id;
  String? title;
  String? img;
  String? image;
  int? type;
  int? doType;
  int? hotValue;
  int? prizesIntegral;
  String? desc;
  String? link;
  String? subTitle;
  List<Prizes>? prizes;
  List<String>? poster;
  List<Rank>? rank;
  bool? isclosed;
  List<Detail>? detail;
  int? status;
  // int get status {
  //   if (detail?.isNotEmpty == true) {
  //     return detail?.first.status ?? 0;
  //   }
  //   return 0;
  // }

  void setStatus(value) {
    // if (detail?.isNotEmpty == true) {
    status = value;
    // }
  }

  String get awardDes {
    if (detail?.isNotEmpty == true && detail?.first.prizes?.isNotEmpty == true) {
      return detail?.first.prizes?.first.name ?? "";
    }
    return "";
  }

  DailyTask({this.id, this.title, this.img, this.type, this.desc,this.subTitle, this.link, this.status});

  DailyTask.fromJson(dynamic json) {
    id = json['id'];
    title = json['title'];
    img = json['img'];
    type = json['type'];
    prizesIntegral = json['prizesIntegral'];
    desc = json['desc'];
    //status = json['status'];
    subTitle = json['subTitle'];
    link = json['link'];
    image = json['image'];
    hotValue = json['hotValue'];
    isclosed = json['isclosed'];
    status = json['status'];
    if (json['detail'] is List) {
      detail = (json['detail'] as List).map((e) => Detail.fromJson(e)).toList();
    }
    if (json['prizes'] != null) {
      prizes = [];
      json['prizes'].forEach((v) {
        prizes?.add(Prizes.fromJson(v));
      });
    }
    if (json['rank'] != null) {
      rank = [];
      json['rank'].forEach((v) {
        rank?.add(Rank.fromJson(v));
      });
    }
    if (json['poster'] != null) {
      poster = [];
      json['poster'].forEach((v) {
        poster?.add(v);
      });
    }
  }

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['title'] = title;
    map['img'] = img;
    map['type'] = type;
    map['image'] = image;
    map['hotValue'] = hotValue;
    map['isclosed'] = isclosed;
    map['prizesIntegral'] = prizesIntegral;
    map['desc'] = desc;
    map['link'] = link;
    if (rank != null) {
      map['rank'] = rank?.map((v) => v.toJson()).toList();
    }
    if (prizes != null) {
      map['prizes'] = prizes?.map((v) => v.toJson()).toList();
    }
    if (poster != null) {
      map['poster'] = poster?.map((v) => v).toList();
    }
    return map;
  }
}

class Rank {
  Rank({
    this.vid,
    this.title,
    this.uid,
    this.name,
    this.cover,
    this.purchased,
    this.bonus,
    this.ranking,
    this.newsType,
  });

  String? vid;
  String? title;
  int? uid;
  String? name;
  String? cover;
  int? purchased;
  int? bonus;
  int? ranking;
  String? newsType;

  factory Rank.fromJson(Map<String, dynamic> json) => Rank(
        vid: json["vid"] == null ? null : json["vid"],
        title: json["title"] == null ? null : json["title"],
        uid: json["uid"] == null ? null : json["uid"],
        name: json["name"] == null ? null : json["name"],
        cover: json["cover"] == null ? null : json["cover"],
        purchased: json["purchased"] == null ? null : json["purchased"],
        bonus: json["bonus"] == null ? null : json["bonus"],
        ranking: json["ranking"] == null ? null : json["ranking"],
        newsType: json["newsType"] == null ? null : json["newsType"],
      );

  Map<String, dynamic> toJson() => {
        "vid": vid == null ? null : vid,
        "title": title == null ? null : title,
        "uid": uid == null ? null : uid,
        "name": name == null ? null : name,
        "cover": cover == null ? null : cover,
        "purchased": purchased == null ? null : purchased,
        "bonus": bonus == null ? null : bonus,
        "ranking": ranking == null ? null : ranking,
        "newsType": newsType == null ? null : newsType,
      };
}

class Detail {
  Detail();

  Detail.fromJson(dynamic json) {
    if (json['prizes'] != null) {
      prizes = [];
      json['prizes'].forEach((v) {
        prizes?.add(Prizes.fromJson(v));
      });
    }
    finishCondition = json['finishCondition'];
    finishCount = json['finishCount'];
    status = json['status'];
  }

  List<Prizes>? prizes;
  num? finishCondition;
  num? finishCount;
  int? status;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (prizes != null) {
      map['prizes'] = prizes?.map((v) => v.toJson()).toList();
    }
    map['finishCondition'] = finishCondition;
    map['finishCount'] = finishCount;
    map['status'] = status;
    return map;
  }
}
